package com.easybuy.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.easybuy.dao.User_addressMapper;
import com.easybuy.pojo.User_address;
@Service
public class AddressServiceImpl implements AddressService {

	@Resource
	private User_addressMapper addressMapper;
	@Override
	public List<User_address> selectAddressByUserId(Integer userId) {
		try {
			return addressMapper.selectAddressByUserId(userId);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}
	
	@Override
	public User_address selectAddressById(Integer id) {
		try {
			return addressMapper.selectAddressById(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	@Override
	public int insertNew(User_address address) {
		try {
			return addressMapper.insertNew(address);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	@Override
	public int deleteAddress(Integer id) {
		try {
			return addressMapper.deleteAddress(id);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	@Override
	public int updateAddress(User_address address) {
		try {
			return addressMapper.updateAddress(address);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	@Override
	public int setdefault(Integer id, Integer userId) {
		try {
			return addressMapper.setdefault(id, userId);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	@Override
	public User_address viewdefault(Integer userId) {
		try {
			return addressMapper.viewdefault(userId);
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

}
